import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = Main.class.getClassLoader().getResourceAsStream("latlon.json");
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            sb.append(line.trim());
        }
        reader.close();

        String content = sb.toString();
        content = content.substring(1, content.length() - 1); // 去掉最外层的 []

        String[] pointStrings = content.split("],\\[");

        List<Point> points = new ArrayList<>();
        for (String pointStr : pointStrings) {
            pointStr = pointStr.replace("[", "").replace("]", ""); // 去掉每个点自身的 []
            String[] coords = pointStr.split(",");
            if (coords.length >= 2) {
                double x = Double.parseDouble(coords[0]);
                double y = Double.parseDouble(coords[1]);
                points.add(new Point(x, y));
            }
        }
        List<Point> test = new ArrayList<>();
        test.add(new Point(119.037089, 32.259867));
        test.add(new Point(118.821489, 32.077388));
        test.add(new Point(118.80657099, 32.0353893));
        test.add(new Point(118.894173, 32.077862));
        Solution solution = new Solution();
        int i =1;
        for (Point point : test) {
            boolean inside = solution.isContain(point, points);
            if (inside) {
                System.out.println("p"+i+"在多边形内部");
            } else {
                System.out.println("p"+i+"不在多边形内部");
            }
            i++;
        }
    }
}
